

public class Player {
    private PackBag bag;
    private int energy;
    public Player(){
        this.energy = 20;
    }
    public void  walk(){
        this.energy -= 10;
        itEnergy();
    }
    public void itEnergy(){
        System.out.println("剩余能量："+energy);
    }
    public boolean isAlive(){
        if (this.energy > 0){
            return true;
        }else {
            System.out.println("你死了");
            return false;
        }
    }

    public void eat(Food food){
        if(food==null){
            System.out.println("房间里没有此食物");
        }else{
        this.energy += food.getEnergy();
        this.itEnergy();
        }
    }
    public void setBag(PackBag bag){
        this.bag = bag;
    }
    public PackBag getBag(){
        return this.bag;
    }
}
